#region Usings

using NUnit.Framework;
using Karma.Framework.Core.IoC;
using Karma.Framework.Core.Test.IoC.Services;

#endregion

namespace Karma.Framework.Core.Test.IoC
{
    [TestFixture]
    public class IoCFixture
    {
        [Test]
        public void ConfiguracionTest()
        {
            //test injection
            var repo = IoCFactory.Resolve<IService>();
            Assert.IsNotNull(repo);
            Assert.AreEqual(repo.GetType(), typeof (Service));
        }

        [Test]
        public void GenericTypeExtensionTest()
        {
            var service = IoCFactory.Resolve<IGenericInterfaceTypeInjectedService>();
            Assert.IsNotNull(service);
            Assert.AreNotEqual(service.GetType(), typeof (GenericInterfaceTypeInjectedService));
            Assert.IsTrue(typeof (IGenericInterfaceTypeInjectedService).IsAssignableFrom(service.GetType()));

            var hi = service.SayHi("Trent");
            Assert.AreEqual("Hi interceptor!!!", hi);
        }

        [Test]
        public void SimpleExtensionTest()
        {
            var service = IoCFactory.Resolve<ISimpleInjectedService>();
            Assert.IsNotNull(service);
            Assert.AreNotEqual(service.GetType(), typeof (SimpleInjectedService));
            Assert.IsTrue(typeof (ISimpleInjectedService).IsAssignableFrom(service.GetType()));

            var hi = service.SayHi("Trent");
            Assert.AreEqual("Hi interceptor!!!", hi);
        }
    }
}